Conditions | 1 |
Paths | 1 |
Total Lines | 78 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | var chai = require('chai'); |
||
11 | describe('regex', function() { |
||
12 | before( function(done) { |
||
13 | Manager.instance.init() |
||
14 | .then(function () { |
||
15 | |||
16 | this.fixture = { |
||
17 | articleSingle: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-single-abe.html'), 'utf8'), |
||
18 | articleEach: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-each-abe.html'), 'utf8'), |
||
19 | articleRequest: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-request.html'), 'utf8') |
||
20 | } |
||
21 | done() |
||
22 | |||
23 | }.bind(this)) |
||
24 | }); |
||
25 | |||
26 | /** |
||
27 | * cmsData.regex.getAttr |
||
28 | */ |
||
29 | it('cmsData.regex.getAttr()', function() { |
||
30 | var attribute = cmsData.regex.getAttr(this.fixture.articleSingle, 'key') |
||
31 | chai.assert.equal(attribute, 'title'); |
||
32 | }); |
||
33 | |||
34 | /** |
||
35 | * cmsData.regex.escapeTextToRegex |
||
36 | */ |
||
37 | it('cmsData.regex.escapeTextToRegex()', function() { |
||
38 | var attribute = cmsData.regex.escapeTextToRegex(this.fixture.articleSingle, 'g') |
||
39 | chai.expect(typeof attribute).to.contain('object'); |
||
40 | }); |
||
41 | |||
42 | /** |
||
43 | * cmsData.regex.isSingleAbe |
||
44 | */ |
||
45 | it('cmsData.regex.isSingleAbe()', function() { |
||
46 | var bool = cmsData.regex.isSingleAbe(this.fixture.articleSingle) |
||
47 | chai.expect(bool).to.be.true; |
||
|
|||
48 | bool = cmsData.regex.isSingleAbe(this.fixture.articleEach) |
||
49 | chai.expect(bool).to.be.false; |
||
50 | }); |
||
51 | |||
52 | /** |
||
53 | * cmsData.regex.isBlockAbe |
||
54 | */ |
||
55 | it('cmsData.regex.isBlockAbe()', function() { |
||
56 | var bool = cmsData.regex.isBlockAbe(this.fixture.articleSingle) |
||
57 | chai.expect(bool).to.be.false; |
||
58 | bool = cmsData.regex.isBlockAbe(this.fixture.articleEach) |
||
59 | chai.expect(bool).to.be.true; |
||
60 | }); |
||
61 | |||
62 | /** |
||
63 | * cmsData.regex.isEachStatement |
||
64 | */ |
||
65 | it('cmsData.regex.isEachStatement()', function() { |
||
66 | var bool = cmsData.regex.isEachStatement(this.fixture.articleSingle) |
||
67 | chai.expect(bool).to.be.false; |
||
68 | bool = cmsData.regex.isEachStatement(this.fixture.articleEach) |
||
69 | chai.expect(bool).to.be.true; |
||
70 | }); |
||
71 | |||
72 | /** |
||
73 | * cmsData.regex.getTagAbeTypeRequest |
||
74 | */ |
||
75 | it('cmsData.regex.getTagAbeTypeRequest()', function() { |
||
76 | var arr = cmsData.regex.getTagAbeTypeRequest(this.fixture.articleSingle) |
||
77 | chai.expect(arr[0]).to.be.undefined; |
||
78 | var arr = cmsData.regex.getTagAbeTypeRequest(this.fixture.articleRequest) |
||
79 | chai.expect(arr[0]).to.not.be.null; |
||
80 | }); |
||
81 | |||
82 | /** |
||
83 | * cmsData.regex.validDataAbe |
||
84 | */ |
||
85 | it('cmsData.regex.validDataAbe()', function() { |
||
86 | // doesn't tested because not sure what it does |
||
87 | }); |
||
88 | }); |